package net.dreamlu.api.oauth;

import java.util.Map;

import net.dreamlu.util.HttpUtil;


/**
 * Oauth BAE
 * @author L.cm
 * @date Jun 24, 2013 9:58:25 PM
 */
public class Oauth {

	private final static String DEFAULTCHAESET = "UTF-8";
	private final static int CONNECTTIMEOUT = 5000;
    private final static int READTIMEOUT = 5000;
	
    private String clientId;
    private String clientSecret;
    private String redirectUri;

	public Oauth() {}

	public String getAuthorizeUrl(String authorize, Map<String, String> params){
		return getAuthorizationCode(authorize, params);
	}
	
	private String getAuthorizationCode(String authorize, Map<String, String> basic) {
        String query = HttpUtil.buildQuery(basic, DEFAULTCHAESET);
        return authorize + "?" + query;
    }
	
	public String doPost(String url, Map<String, String> params) {
        return HttpUtil.doPost(url, params, CONNECTTIMEOUT, READTIMEOUT);
    }
	
	public String doGet(String url, Map<String, String> params) {
        return HttpUtil.doGet(url, params, DEFAULTCHAESET);
    }
	
	public String getClientId() {
		return clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	public String getClientSecret() {
		return clientSecret;
	}

	public void setClientSecret(String clientSecret) {
		this.clientSecret = clientSecret;
	}

	public String getRedirectUri() {
		return redirectUri;
	}

	public void setRedirectUri(String redirectUri) {
		this.redirectUri = redirectUri;
	}
}
